<template>
	<view>
		<view class="dengji">
			<view class="box">
				<view class="title">综合评定等级：</view>
				<view class="dec">{{pingjia}}</view>
			</view>
			<image v-if="dengji=='S'" src="/static/image/dengji/S.png"></image>
			<image v-if="dengji=='A'" src="/static/image/dengji/A.png"></image>
			<image v-if="dengji=='B'" src="/static/image/dengji/B.png"></image>
			<image v-if="dengji=='C'" src="/static/image/dengji/C.png"></image>
		</view>
		<view class="qingdan">
			<view class="title">领域评分</view>
			<view class='fps'>
				<view class='item'>
					<view><text style="margin-left: 40rpx;">办公</text></view>
					<view>{{score2.gumu}}<span v-if='score.gumu!="暂无数据"'>分</span></view>
				</view>
				<view class='item'>
					<view><text style="margin-left: 40rpx;">娱乐</text></view>
					<view>{{score2.aodesai}}<span v-if='score.aodesai!="暂无数据"'>分</span></view>
				</view>
				<view class='item'>
					<view><text style="margin-left: 40rpx;">编程</text></view>
					<view>{{score2.chiji}}<span v-if='score.chiji!="暂无数据"'>分</span></view>
				</view>
			</view>
		</view>
		<view class="qingdan">
			<view class="totalPrice">
				<view class="title">总价</view>
				<view class="number"><text style="color: #1296db;margin-left: 20rpx;">{{totalPrice1}}元</text></view>
			</view>
		</view>
		<view class="qingdan">
			<view class="title">清单列表</view>
			<view class="list">
				<OptionList :options="checked" :ceping="true"></OptionList>
			</view>
		</view>
	</view>
</template>

<script>
	import computedFPS from '../../../untiljs/fpscomputed.js'
	import computedFPS2 from '../../../untiljs/fpscomputed2.js'
	import diydetailsVue from '../diydetails/diydetails.vue'
	const db = wx.cloud.database();
	const _ = db.command;
	let totalPrice = 0;
	export default {
		data() {
			return {
				checked: {},
				score: null,
				score2: null,
				dengji: '',
				pingjia: '',
				totalPrice1:0,
			}
		},
		onLoad(evt) {
			console.log("evt")
			console.log(evt)
			this.checked = JSON.parse(evt.checked)
			this.score = computedFPS(this.checked.xianka)
			this.score2 = computedFPS2(this.checked.cpu, this.checked.xianka, this.checked.neicun)
			if (this.score.gumu == '暂无数据') {
				this.dengji = 'A',
					this.pingjia = '暂未匹配到合适的数据！'
			} else {
				var all = this.score.gumu * 3 + this.score.chiji * 3.5 + this.score.aodesai * 4;
				if (all <= 300) {
					this.dengji = 'C'
					this.pingjia = '性能比较差，可以进行低损耗商务办公运作！'
				} else if (all > 300 && all <= 450) {
					this.dengji = 'B'
					this.pingjia = '性能一般，可以应对寻常场景编程办公！'
				} else if (all > 450 && all <= 600) {
					this.dengji = 'A'
					this.pingjia = '性能优秀，可以畅玩绝大部分3A游戏佳作！'
				} else {
					this.dengji = 'S'
					this.pingjia = '性能极高，可以享受高画质3A游戏的极致体验！'
				}
			}
			db.collection('cpu').where({
				name: _.eq(this.checked.cpu)
			}).get().then(res => {
				totalPrice += res.data[0].price;
				db.collection('xianka').where({
					name: _.eq(this.checked.xianka)
				}).get().then(res => {
					totalPrice += res.data[0].price;
					//console.log('totalprice:', totalPrice)
					db.collection('zhuban').where({
						name: _.eq(this.checked.zhuban)
					}).get().then(res => {
						// console.log('zhubanPrice:', res.data[0].price)
						totalPrice += res.data[0].price;
						db.collection('neicun').where({
							name: _.eq(this.checked.neicun)
						}).get().then(res => {
							// console.log('neicunPrice:', res.data[0].price)
							totalPrice += res.data[0].price;
							db.collection('yingpan').where({
								name: _.eq(this.checked.yingpan)
							}).get().then(res => {
								// console.log('yingpanPrice:', res.data[0].price)
								totalPrice += res.data[0].price;
								db.collection('sanreqi').where({
									name: _.eq(this.checked.sanreqi)
								}).get().then(res => {
									// console.log('sanrePrice:', res.data[0].price)
									totalPrice += res.data[0].price;
									db.collection('dianyuan').where({
										name: _.eq(this.checked.dianyuan)
									}).get().then(res => {
										//console.log('dianyuanPrice:', res.data[0].price)
										totalPrice += res.data[0]
											.price;
										db.collection('jixiang')
											.where({
												name: _.eq(this.checked.jixiang)
											}).get().then(res => {
												//console.log('jixiangPrice:', res.data[0].price)
												totalPrice += res.data[0].price;
												console.log('totalPrice:', totalPrice)
												this.totalPrice1 = totalPrice;
											})
									})
								})
							})
						})
					})
				})
			})
		},
		
	}
</script>

<style lang="scss" scoped>
	.box {
		display: flex;
		flex-direction: column;
		justify-content: space-around;
	}

	.dengji {
		display: flex;
		flex-direction: row;
		background-color: white;
		padding: 5px;

		.dec {
			color: #1296db;
			font-size: 14px;
			margin-left: 3vw;
			margin-top: 2vh;
			margin-right: 3vw;
		}

		image {
			width: 40vw;
			height: 20vh;
		}
	}

	.qingdan {
		background-color: white;
		padding: 5px;
	}

	.title {
		font-weight: bold;
		padding: 2vh 0px 0px 3vw;
	}

	.top {
		background-color: white;
		padding: 5px;
	}

	.fps {
		.item {
			display: flex;
			flex-direction: row;
			width: 110vw;
			height: 10vh;
			line-height: 10vh;
			border-bottom: 1px solid #F1F1F1;
		}

		.item :first-child {
			width: 70vw;
		}

		.item :last-child {
			width: 40vw;
			color: #1296db;
		}
	}

	.list {
		width: 90vw;
	}
	.totalPrice{
		height: 10vh;
	}
	.number{
		margin-top:35rpx;
		margin-left:25rpx;
	}
</style>
